/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package consumo.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Carlos Taschetto
 */
@Entity
@Table(name = "mm_cabecalho", catalog = "consumodb", schema = "")
@NamedQueries({
    @NamedQuery(name = "MmCabecalho.findAll", query = "SELECT m FROM MmCabecalho m"),
    @NamedQuery(name = "MmCabecalho.findById", query = "SELECT m FROM MmCabecalho m WHERE m.id = :id")})
public class MmCabecalho implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Lob
    @Column(name = "texto", length = 65535)
    private String texto;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "mmCabecalho")
    private List<MmListagem> mmListagemList;
    @JoinColumn(name = "leitura_id", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Leitura leituraId;

    public MmCabecalho() {
    }

    public MmCabecalho(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTexto() {
        return texto;
    }

    public void setTexto(String texto) {
        this.texto = texto;
    }

    public List<MmListagem> getMmListagemList() {
        return mmListagemList;
    }

    public void setMmListagemList(List<MmListagem> mmListagemList) {
        this.mmListagemList = mmListagemList;
    }

    public Leitura getLeituraId() {
        return leituraId;
    }

    public void setLeituraId(Leitura leituraId) {
        this.leituraId = leituraId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MmCabecalho)) {
            return false;
        }
        MmCabecalho other = (MmCabecalho) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "consumo.persistence.MmCabecalho[id=" + id + "]";
    }

}
